import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "../layout/layout_main/index.vue";

Vue.use(VueRouter);

/**
 * 懒加载
 * {
    path: "/about",
    name: "About",
    component: () => import("../views/About.vue")
  }
 */

const routes = [
    {
        path: "/",
        name: "Login",
        component: () => import("../views/login/index.vue")
    },
    {
        path: "/perfect",
        name: "Perfect",
        component: () => import("../views/login/perfect.vue")
    },
    {
        path: "/home",
        redirect: "/home/index",
        name: "Home",
        component: Layout,
        children: [
            {
                path: "index",
                name: "home",
                meta: {
                    key: "Home",
                    title: "首页"
                    // keepAlive: true
                },
                component: () => import("../views/home/index.vue")
            }
        ]
    },
    {
        path: "/class",
        redirect: "/class/index",
        name: "Class",
        component: Layout,
        children: [
            {
                path: "index",
                name: "class",
                meta: {
                    key: "Class",
                    title: "班级"
                },
                component: () => import("../views/class/index.vue")
            },
            {
                path: "searchClass",
                name: "SearchClass",
                meta: {
                    key: "SearchClass",
                    title: "班级列表"
                },
                component: () => import("../views/class/searchClass.vue")
            }
        ]
    },
    {
        path: "/IntelligentPromotion",
        redirect: "/IntelligentPromotion/index",
        name: "IntelligentPromotion",
        component: Layout,
        children: [
            {
                path: "index",
                name: "intelligentPromotion",
                meta: {
                    key: "IntelligentPromotion",
                    title: "智提升"
                },
                component: () =>
                    import("../views/IntelligentPromotion/index.vue")
            }
        ]
    },
    {
        path: "/personalCenter",
        redirect: "/personalCenter/index",
        name: "PersonalCenter",
        component: Layout,
        children: [
            {
                path: "index",
                name: "personalCenter",
                meta: {
                    key: "PersonalCenter",
                    title: "个人中心"
                },
                component: () => import("../views/personalCenter/index.vue")
            },
            {
                path: "personalHomepage",
                name: "personalHomepage",
                meta: {
                    key: "personalHomepage",
                    title: "个人主页"
                },
                component: () =>
                    import("../views/personalCenter/personalHomepage.vue")
            },
            {
                path: "addSelfTable",
                name: "addSelfTable",
                meta: {
                    key: "addSelfTable",
                    title: "新增自订课表"
                },
                component: () =>
                    import("../views/personalCenter/newSelfTable.vue")
            }
        ]
    },
    // 同步
    {
        path: "/synchronization/practice",
        redirect: "/synchronization/practice/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "练习"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/synchronization/practice/index.vue")
            }
        ]
    },
    {
        path: "/synchronization/startPracticing",
        redirect: "/synchronization/startPracticing/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "开始练习"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/synchronization/startPracticing/index.vue")
            }
        ]
    },
    {
        path: "/synchronization/intellectualReport",
        redirect: "/synchronization/intellectualReport/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "智学报告"
                },
                path: "index",
                name: "index",
                component: () =>
                    import(
                        "../views/synchronization/intellectualReport/index.vue"
                    )
            }
        ]
    },
    // 趣练
    {
        path: "/InterestingPractice/practice",
        redirect: "/InterestingPractice/practice/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "趣练"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/InterestingPractice/practice/index.vue")
            }
        ]
    },
    {
        path: "/InterestingPractice/breakThrough",
        redirect: "/InterestingPractice/breakThrough/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "正在趣练"
                },
                path: "index",
                name: "index",
                component: () =>
                    import(
                        "../views/InterestingPractice/breakThrough/index.vue"
                    )
            }
        ]
    },
    {
        path: "/InterestingPractice/breakResult",
        redirect: "/InterestingPractice/breakResult/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "趣练报告"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/InterestingPractice/breakResult/index.vue")
            }
        ]
    },
    // 测验
    {
        path: "/test/selectClass",
        redirect: "/test/selectClass/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "选择班级"
                },
                path: "index",
                name: "index",
                component: () => import("../views/test/selectClass/index.vue")
            }
        ]
    },
    {
        path: "/test/classTest",
        redirect: "/test/classTest/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "班级测验"
                },
                path: "index",
                name: "index",
                component: () => import("../views/test/index.vue")
            }
        ]
    },
    {
        path: "/test/beginExam",
        redirect: "/test/beginExam/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "开始考试"
                },
                path: "index",
                name: "index",
                component: () => import("../views/test/beginExam/index.vue")
            }
        ]
    },
    {
        path: "/test/testReport",
        redirect: "/test/testReport/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "测验报告"
                },
                path: "index",
                name: "index",
                component: () => import("../views/test/testReport/index.vue")
            }
        ]
    },
    // 作业
    {
        path: "/work/selectClass",
        redirect: "/work/selectClass/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "选择班级"
                },
                path: "index",
                name: "index",
                component: () => import("../views/work/selectClass/index.vue")
            }
        ]
    },
    {
        path: "/work/classWork",
        redirect: "/work/classWork/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "班级作业"
                },
                path: "index",
                name: "index",
                component: () => import("../views/work/index.vue")
            }
        ]
    },
    {
        path: "/work/preview/list",
        redirect: "/work/preview/list/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "开始预习"
                },
                path: "index",
                name: "index",
                component: () => import("../views/work/preview/list/index.vue")
            }
        ]
    },
    {
        path: "/work/preview",
        redirect: "/work/preview/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "预习"
                },
                path: "index",
                name: "index",
                component: () => import("../views/work/preview/index.vue")
            }
        ]
    },
    {
        path: "/work/beginWork",
        redirect: "/work/beginWork/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "班级考试"
                },
                path: "index",
                name: "index",
                component: () => import("../views/work/beginWork/index.vue")
            }
        ]
    },
    // 题目解析
    {
        path: "/topicAnalysis/all",
        redirect: "/topicAnalysis/all/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "题目解析"
                },
                path: "index",
                name: "index",
                component: () => import("../views/topicAnalysis/all/index.vue")
            }
        ]
    },
    // 错题解析
    {
        path: "/topicAnalysis/wrong",
        redirect: "/topicAnalysis/wrong/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "错题解析"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/topicAnalysis/wrong/index.vue")
            }
        ]
    },
    // 自行批改
    {
        path: "/topicAnalysis/selfGrade",
        redirect: "/topicAnalysis/selfGrade/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "自行批改"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/topicAnalysis/selfGrade/index.vue")
            }
        ]
    },
    // 订正错题
    {
        path: "/topicAnalysis/wrongTask",
        redirect: "/topicAnalysis/wrongTask/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "错题解析"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/topicAnalysis/wrongTask/index.vue")
            }
        ]
    },
    // 自评
    {
        path: "/selfEvaluation/practice",
        redirect: "/selfEvaluation/practice/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "自评"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/selfEvaluation/practice/index.vue")
            }
        ]
    },
    {
        path: "/selfEvaluation/ready",
        redirect: "/selfEvaluation/ready/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "自评"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/selfEvaluation/ready/index.vue")
            }
        ]
    },
    {
        path: "/selfEvaluation/examination",
        redirect: "/selfEvaluation/examination/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "正在考试"
                },
                path: "index",
                name: "index",
                component: () =>
                    import("../views/selfEvaluation/examination/index.vue")
            }
        ]
    },
    {
        path: "/selfEvaluation/selfEvaluationReport",
        redirect: "/selfEvaluation/selfEvaluationReport/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "自评报告"
                },
                path: "index",
                name: "index",
                component: () =>
                    import(
                        "../views/selfEvaluation/selfEvaluationReport/index.vue"
                    )
            }
        ]
    },
    {
        path: "/selfEvaluation/selfEvaluationWrong",
        redirect: "/selfEvaluation/selfEvaluationWrong/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "错题解析"
                },
                path: "index",
                name: "index",
                component: () =>
                    import(
                        "../views/selfEvaluation/selfEvaluationWrong/index.vue"
                    )
            }
        ]
    },
    // 智题本
    {
        path: "/wisdomBook/wisdomList",
        redirect: "/wisdomBook/wisdomList/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "错题解析"
                },
                path: "index",
                name: "index",
                component: () => import("../views/wisdomBook/index.vue")
            }
        ]
    },
    // 智题本
    {
        path: "/wisdomBook/chapter",
        redirect: "/wisdomBook/chapter/index",
        name: "Index",
        component: Layout,
        children: [
            {
                meta: {
                    key: "",
                    title: "章节详情"
                },
                path: "index",
                name: "index",
                component: () => import("../views/wisdomBook/chapter/index.vue")
            }
        ]
    },

    // 404 page must be placed at the end !!!
    {
        path: "/404",
        component: () => import("@/views/404")
    },
    {
        path: "*",
        redirect: "/404"
    }
];

const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes
});

export default router;
